<template>
  <div class="nav">
    <div class="toggle-menu-breadcrumb">
      <el-breadcrumb>
        <el-breadcrumb-item>当前</el-breadcrumb-item>
        <el-breadcrumb-item>{{ menuStore.breadcrumb }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="user">
      <el-dropdown>
        <span class="el-dropdown-link">
              {{loginStore.username}}
          <el-icon class="el-icon--right">
            <arrow-down/>
          </el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="HomepageHandler">回到主页</el-dropdown-item>

            <el-dropdown-item @click="UserCenterHandler">个人中心</el-dropdown-item>

            <el-dropdown-item @click="logoutHandler">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>


<script setup lang="ts">
import {ArrowDown} from '@element-plus/icons-vue'
import {useLoginStore} from "@/stores/loginStore"
import router from "@/router/index"
import {usemenuStore} from "@/stores/menuStore"
const menuStore =  usemenuStore()
const loginStore = useLoginStore()

const logoutHandler = () => {
  // loginStore.token = ""
  // loginStore.status = ""
  // loginStore.username = ""
  // loginStore.password = ""
  loginStore.$reset()
  router.push("/Homepage")

}
const UserCenterHandler = () =>{
  router.push("/ucenter")
}
const HomepageHandler = () => {
  router.push("/Homepage")
}

</script>

<style scoped>

.nav {
  width: 100%;
  height: 60px;
  background-color: #fff;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 /12%), 0 0 3px 0 rgb(0 0 0 / 4%);
}

.toggle-menu-breadcrumb {
  float: left;
  margin-top: 20px;
  margin-left: 20px;
}

.user {
  font-size: 15px;
  float: right;
  margin-right: 40px;
  margin-top: 20px;

}

.example-showcase .el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
}
</style>